using System;
using System.IO;
using System.Reflection;

namespace DynamicConfigurationManager.ConfigMapAttributes
{
    /// <summary>
    /// AssemblyPath compares the value to the assembly path of the application hosts current directory.
    /// </summary>
    internal class AssemblyPath : IConfigMapAttribute
    {
        public bool Execute(string configMapAttribute)
        {
            var assemblyPath = Assembly.GetExecutingAssembly().CodeBase;
            LogHelper.Append("AssemblyPath: matching to {0}", assemblyPath);
            var fullPath = Path.GetFullPath(configMapAttribute.TrimEnd('\\'));
            return fullPath.Equals(assemblyPath, StringComparison.InvariantCultureIgnoreCase);
        }
    }
}